package com.example.service.impl;

import com.example.entity.UploadFile;
import com.example.entity.example.UploadFileExample;
import com.example.mapper.UploadFileMapper;
import com.example.service.UploadFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class UploadFileServiceImpl implements UploadFileService {

    @Autowired(required = false)
    UploadFileMapper uploadFileMapper;

    @Override
    public List<UploadFile> getByExampleWithLimit(Integer id, String username, String fileName, Date beginDate, Date endDate, Integer curPage, Integer pageSize) {
        int begin = (curPage - 1) * pageSize;
        return uploadFileMapper.selectByExampleWithLimit(id, username, fileName, beginDate, endDate, begin, pageSize);
    }

    @Override
    public int getCountByExample(Integer id, String username, String fileName, Date beginDate, Date endDate) {
        return uploadFileMapper.getCountByExample(id,username,fileName,beginDate,endDate);
    }

    @Override
    public UploadFile getById(Integer id) {
        return uploadFileMapper.selectByPrimaryKey(id);
    }

    @Override
    public void addUploadFile(UploadFile uploadFile) {
        uploadFileMapper.insert(uploadFile);
    }

    @Override
    public void removeById(Integer id) {
        uploadFileMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void updateSelectiveById(UploadFile uploadFile) {
        uploadFileMapper.updateByPrimaryKeySelective(uploadFile);
    }

    @Override
    public long getCountByExample(UploadFileExample example) {
        return uploadFileMapper.countByExample(example);
    }
}
